package cn.limc.ohoscharts.demo.slice;

import cn.limc.ohoscharts.demo.ResourceTable;
import cn.limc.ohoscharts.entity.TitleValueEntity;
import cn.limc.ohoscharts.view.RadarChart;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;

import java.util.ArrayList;
import java.util.List;

public class RadarChartAbility extends AbilitySlice {

  RadarChart radarchart;

  @Override
  public void onStart(Intent intent) {
    super.onStart(intent);
    super.setUIContent(ResourceTable.Layout_ability_radar_chart);
    initRadarChart();
  }

  private void initRadarChart() {
    this.radarchart = (RadarChart) findComponentById(ResourceTable.Id_radarchart);

    final List<TitleValueEntity> data1 = new ArrayList<TitleValueEntity>();
    data1.add(new TitleValueEntity("Alpha", 3));
    data1.add(new TitleValueEntity("Bravo", 4));
    data1.add(new TitleValueEntity("Charlie", 9));
    data1.add(new TitleValueEntity("Delta", 8));
    data1.add(new TitleValueEntity("Echo", 10));

    final List<TitleValueEntity> data2 = new ArrayList<TitleValueEntity>();
    data2.add(new TitleValueEntity("Alpha", 3));
    data2.add(new TitleValueEntity("Bravo", 4));
    data2.add(new TitleValueEntity("Charlie", 5));
    data2.add(new TitleValueEntity("Delta", 6));
    data2.add(new TitleValueEntity("Echo", 7));

    final List<List<TitleValueEntity>> data = new ArrayList<List<TitleValueEntity>>();
    data.add(data1);
    data.add(data2);

    radarchart.setData(data);
    radarchart.setLatitudeNum(5);
  }

}
